//
//  VRMyAdressCell.m
//  VRFirefighting
//
//  Created by Veer on 2018/8/23.
//  Copyright © 2018年 Veer. All rights reserved.
//

#import "VRMyAdressCell.h"

#import "VRMyAdressModel.h"

@interface VRMyAdressCell()


@property (nonatomic, weak) UIImageView *iconImgView;
@property (nonatomic, weak) UILabel *nameLbl;
@property (nonatomic, strong) UILabel *mobileLbl;

@property (nonatomic, assign) UIView *bottomLineView;

@end

@implementation VRMyAdressCell

+ (instancetype)cellWith:(UITableView *)tablevie
{
    static NSString *cellID = @"VRMyAdressCell";
    
    VRMyAdressCell *cell = [tablevie dequeueReusableCellWithIdentifier:cellID];
    
    if (nil == cell) {
        
        cell = [[VRMyAdressCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.accessoryType = UITableViewCellAccessoryNone;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        // lieview
        [self setupSubView];
        
    }
    return self;
}


- (void)setupSubView
{
    
    UIView *selectedBgView = [[UIView alloc] init];
    selectedBgView.backgroundColor = RGB(238, 238, 238);
    self.selectedBackgroundView = selectedBgView;
    
    UIImageView *iconImgView = [[UIImageView alloc] init];
    iconImgView.image = [UIImage imageNamed:@"my_address"];
    iconImgView.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:iconImgView];
    self.iconImgView = iconImgView;
    
    UILabel *nameLbl = [[UILabel alloc] init];
    nameLbl.numberOfLines = 2;
    nameLbl.textColor = MAINColor;
    nameLbl.font = VRFont(16);
    [self.contentView addSubview:nameLbl];
    self.nameLbl = nameLbl;
    
    UIView *bottomLineView = [[UIView alloc] init];
    bottomLineView.backgroundColor = RGB(228, 228, 228);
    [self.contentView addSubview:bottomLineView];
    self.bottomLineView = bottomLineView;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.centerY.mas_equalTo(self.contentView);
        make.width.mas_equalTo(20);
        make.height.mas_equalTo(20);
    }];
    
    [self.nameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.iconImgView.mas_right).offset(10);
        make.centerY.mas_equalTo(self.iconImgView);
        make.right.mas_equalTo(-20);
    }];
    
    [self.bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(-0);
        make.bottom.mas_equalTo(self.contentView);
        make.height.mas_equalTo(1);
    }];
}



#pragma mark - setter && getter
- (void)setModel:(VRMyAdressModel *)model
{
    _model = model;
    
    self.nameLbl.text = model.address;
    
}

@end
